<?php

namespace Mobile\Controller;



use Think\Controller;



class IndexController extends Controller

{
    /**

     * 商品列表

     */
    public function goods_list()

    {

        $sid = I('sid');
        $where = array(
            'g.s_id' => $sid,
            'g.is_show' => 1,
             );
        $list['goods'] = M('goods')->where($where)->join('as g left join sp_goods_cate as c ON g.goods_cate_id = c.goods_cate_id')->order('g.sort desc')->select();

        $list['shop']= M('store')->where('s_id='.$sid)->find();
        $list['shop']['thumb'] =  str_replace("./Uploads",'http://commission.weiyuekj.com/Uploads',$list['shop']['thumb']);

        foreach( $list['goods'] as $k => &$v ){
           $idArr[] = $v['goods_id'];
            $v['default_img'] =  str_replace("./Uploads",'http://commission.weiyuekj.com/Uploads',$v['default_img']);
            $v['cover_small'] =  str_replace("./Uploads",'http://commission.weiyuekj.com/Uploads',$v['cover_small']);
        }

        $idStr = implode(',',$idArr);

        //查询产品包
        if($idStr){
            $list['package']  = M()->query("select * from sp_goods_spec_option where goods_id in($idStr) AND checked=0");
        }

    //p($list);
        echo json_encode($list);

    }


}

